﻿// =================================================================== 
// 项目说明
//====================================================================
// 陕西龙源  @Copy Right 2006-2008
// 文件： SYS_USER.cs
// 项目名称：供电企业管理信息系统



// 创建时间：2010-03-19
// 负责人：
// ===================================================================
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using CommonLib.Model;
using CommonLib.IDAL;


namespace MSSQLDAL
{
    /// <summary>
    /// 数据层实例化接口类  .
    /// </summary>
    public partial class SYS_USERDAL : ISYS_USERDAL
    {
        //此处写查询数据的sql语句，



        //if QueryDataString==""，DAL层的GetList，GetRecordCount等函数将直接存取SYS_USER表



        //if QueryDataString!=""，则DAL层的GetList，GetRecordCount等函数将存取该SQL语句，取代表
        //注意：所写sql语句执行结果的字段必须是唯一的



        private const string QueryDataString = "Select a.*,b.DEPT_NAME From sys_user a,sys_dept b where a.dept_id=b.dept_id";

        public DataSet CheckUserData(string user_id, string password)
        {
            DataSet ds = new DataSet();
            string sFieldValue = "";
            if (password == "")
                return ds;

            String strSql = "Select a.user_id,a.user_password,a.other_user1,a.other_user2,a.user_name,a.IS_MANAGER,b.dept_id,b.dept_name,b.dept_index,b.for_supply From sys_user a,sys_dept b "
                         + " where a.user_id=@user_id and a.dept_id=b.dept_id ";
            SqlParameter para=new SqlParameter("@user_id",user_id);
            ds = SqlHelper.ExecuteDataset(Conn.SqlConnStr, CommandType.Text, strSql.ToString(), para);

            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    sFieldValue = ds.Tables[0].Rows[0]["user_password"].ToString();
                    if (password != CommonLib.ComMon.StringCommon.StringDecode(sFieldValue))
                    {
                        return new DataSet();
                    }
                }
                else
                {
                    return new DataSet();
                }
            }
            return ds;
        }

    }
}
